﻿/// Name - Common.Question v1.1
/// Description - An instance of this class object represents a particular question to be presented to the user.
///     Depending on the type specified using the embedded enumeration, different characteristics of this object
///     are expected.  If a CheckBox style control is to be presented, it is expected to have one or more ListItem
///     type controls included in ChildItems to be used as answers.  If a RadioButton style control is to be presented,
///     it is expected to have one or more ListItem type controls included in ChildItems to be used as answers.  If
///     a TextBox style control is to be presented, no ChildItems are needed.  A ListItem is only to be used for 
///     CheckBoxes or RadioButton type parent controls.  A Literal type is used to display HTML or other basic information
///     without any answer control.
///     Additionally, since the content each instance could change, the Locked flag controls whether the information
///     can be changed or not.  This is needed if downstream logic is based on information that needs to stay static, like
///     the Question ID.
/// Programmer - Dan Yatzeck
/// Date coded - 11/3/2011
/// Arguments - None
/// Variables -
///        QuestionID - Question index ID
///        PageID - Page index ID
///        QuestionText - String value for text of the question to be asked
///        Answered - Whether the question is answered or not
///        AnswerText - Actual answer provided
///        AnswerControlType - Enumerated question type to determine the control to be displayed
///        ParentQuestionID - If this is a child item, this is the parent Question index ID
///        ChildItems - List of answer options if the control type requires it
///        HelpText - Popup message if more information is desired
///        RegExValidation - Valdiation expression for RegEx validation control
///        RegExMessage - Message to be displayed if RegEx validation fails
///        Required - Required flag for required validation control
///        RequiredMessage - Message to be displayed if Required validation fails
///        Locked - Locked flag indicates whether the question text/answer data can be changed
///        ShowOnPrintout - Flag indicating whether the question text and control appears on print view
/// Files accessed by this code artifact - None
/// Files changed by this code artifact - None
/// I/O - None
/// Error Handling - None
/// Modifications -
///     1.0 - Initial coding
///     1.1 - (11/6/2011) Added Literal control type
///     1.2 - (11/30/2011) Added ShowOnPrintout variable
/// Known Faults -
///     1.0 - Implementation is highly dependent on the design of this class, and only allowed controls
///         can be used
///     1.1 - Same as 1.0
///     1.2 - Same as 1.1

using System.Collections.Generic;

namespace Common
{
    /// <summary>
    /// This class defines a question to be presented to the user
    /// </summary>
    public class Question
    {
        // Allowed control types in implementation
        public enum Types
        {
            CheckBox,
            ListItem,
            RadioButton,
            TextBox,
            Literal
        };

        public int QuestionID { get; set; }
        public int PageID { get; set; }

        public string QuestionText { get; set; }
        
        public bool Answered { get; set; }
        public string AnswerText { get; set; }
        public Types AnswerControlType { get; set; }

        public int ParentQuestionID { get; set; }
        public List<Question> ChildItems { get; set; } // used for answer control(s)
        
        public HelpText HelpText { get; set; }

        // Set the RegEx Validation expression and message to display if the validation fails
        public string RegExValidation { get; set; }
        public string RegExMessage { get; set; }
        // Set the Required validation flag and message to display if the validation fails
        public bool Required { get; set; }
        public string RequiredMessage { get; set; }

        public bool Locked { get; set; } // can or cannot be changed from admin interface (used if other logic is based upon answering this question)

        public bool ShowOnPrintout { get; set; } // determines if the text and control show on print view
    }
}
